package com.yang.dubbo.controller;

import com.yang.dubbo.model.Member;
import com.yang.dubbo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
    UserService us;

    //@HystrixCommand(fallbackMethod = "hiHystrix")
    @PostMapping("/buy")
    public String bug(){
        return us.buyTicket();
    }

//    public String hiHystrix(){
//        return "Hystrix。。。。。";
//    }

//    @HystrixCommand(fallbackMethod = "hystrixAddStudent", commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000")
//    })
    @PostMapping("/queryAll")
    public List<Member> queryAll(){
        return us.queryAll();
    }

//    public List<Member> hystrixAddStudent(){
//        List<Member> menberList = new ArrayList<>();
//        Member m = new Member();
//        m.setId(120);
//        m.setName("熔断");
//        m.setMeallist(null);
//        menberList.add(m);
//        return menberList;
//    }

    @PostMapping("/insertAll")
    public Map<String, Object> insertAll() {
        return us.insertAll();
    }
}
